#include "StdAfx.h"
#include "CircuitSimVector.h"

CCircuitSimVector::CCircuitSimVector(void)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblColor[0] = 0;
	m_dblColor[1] = 0;
	m_dblColor[2] = 0;
	m_bSelected = false;
	m_szColumn = _T("");
}

CCircuitSimVector::CCircuitSimVector(const CCircuitSimVector *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblPosX = pEntityObj->GetPosX();
	m_dblPosY = pEntityObj->GetPosY();
	m_dblColor[0] = pEntityObj->GetColorR();
	m_dblColor[1] = pEntityObj->GetColorG();
	m_dblColor[2] = pEntityObj->GetColorB();
	m_bSelected = pEntityObj->GetSelect();
	m_szColumn = pEntityObj->GetColumn();
}

CCircuitSimVector::CCircuitSimVector(CICircuit *pParentEnt)
	: CCircuitUnit(pParentEnt)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblColor[0] = 0;
	m_dblColor[1] = 0;
	m_dblColor[2] = 0;
	m_bSelected = false;
	m_szColumn = _T("");
}

CCircuitSimVector::~CCircuitSimVector(void)
{
	Clear();
}

void CCircuitSimVector::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblPosX;
		ar << m_dblPosY;
		ar << m_dblColor[0];
		ar << m_dblColor[1];
		ar << m_dblColor[2];
		ar << m_bSelected;
		CObj::WriteString(ar, m_szColumn);
	}
	else
	{
		ar >> m_dblPosX;
		ar >> m_dblPosY;
		ar >> m_dblColor[0];
		ar >> m_dblColor[1];
		ar >> m_dblColor[2];
		ar >> m_bSelected;
		CObj::ReadString(ar, m_szColumn);
	}
	
	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitSimVector::Clone() const
{
	return new CCircuitSimVector(this);
}

void CCircuitSimVector::Transform(const CMatrix transf)
{

}

bool CCircuitSimVector::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitSimVector::Clear()
{

}

void CCircuitSimVector::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitSimVector::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitSimVector::CreateDisplayObj(long lLayerId)
{
	CCircuitSimVectorDisObj *pCirVector = new CCircuitSimVectorDisObj(this);
	pCirVector->SetLayerId(lLayerId);
	return pCirVector;
}

void CCircuitSimVector::CalcBox()
{
	m_minX = m_dblPosX-10;
	m_minY = m_dblPosY;
	m_maxX = m_dblPosX;
	m_maxY = m_dblPosY+10;
}

eCircuitUnitEntType CCircuitSimVector::GetUnitType() const
{
	return CIRCUIT_TEST_VECTOR;
}

double CCircuitSimVector::GetPosX() const
{
	return m_dblPosX;
}

double CCircuitSimVector::GetPosY() const
{
	return m_dblPosY;
}

double CCircuitSimVector::GetColorR() const
{
	return m_dblColor[0];
}

double CCircuitSimVector::GetColorG() const
{
	return m_dblColor[1];
}

double CCircuitSimVector::GetColorB() const
{
	return m_dblColor[2];
}

bool CCircuitSimVector::GetSelect() const
{
	return  m_bSelected;
}

CString CCircuitSimVector::GetColumn() const
{
	return m_szColumn;
}

void CCircuitSimVector::SetPosX( double dblPosX)
{
	m_dblPosX = dblPosX;
}

void CCircuitSimVector::SetPosY( double dblPosY)
{
	m_dblPosY = dblPosY;
}

void CCircuitSimVector::SetColorR( double colR)
{
	m_dblColor[0] = colR;
}

void CCircuitSimVector::SetColorG( double colG)
{
	m_dblColor[1] = colG;
}

void CCircuitSimVector::SetColorB( double colB)
{
	m_dblColor[2] = colB;
}

void CCircuitSimVector::SetSelect( bool bSelected)
{
	m_bSelected = bSelected;
}


void CCircuitSimVector::SetColumn( CString szColumn)
{
	m_szColumn = szColumn;
}
